﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="xbrlesita_vastus", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(XbrlesitaVastus))]
    public class XbrlesitaVastusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IXbrlesitaVastus clazz;
        
        public XbrlesitaVastusSerializer(IXbrlesitaVastus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("status");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Status))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("status_text");
            if (clazz.StatusText!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.StatusText))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            if (clazz.MajpaevikPaevNr!=null) {
                Writer.WriteStartElement("majpaevik_paev_nr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.MajpaevikPaevNr))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="status") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_vastus>status");
                }
                clazz.Status = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("status")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_vastus>status", Reader.LocalName);
            }
            if (Reader.LocalName=="status_text") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.StatusText = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("status_text")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_vastus>status_text", Reader.LocalName);
            }
            if (Reader.LocalName=="majpaevik_paev_nr") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_vastus>majpaevik_paev_nr");
                }
                clazz.MajpaevikPaevNr = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("majpaevik_paev_nr")).Value;
            }
        }
    }
}
